<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<!-- NB: xmlns:rich is needed as a workaround for ZNTA-674 -->

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:composite="http://java.sun.com/jsf/composite"
  xmlns:zanata="http://java.sun.com/jsf/composite/zanata"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:rich="http://richfaces.org/rich">

<composite:interface>
  <composite:attribute name="actionBean" type="org.zanata.ui.CopyAction"
    shortDescription="action bean for copy process"
    required="true"/>

  <composite:attribute name="canCancelProcess" type="java.lang.Boolean"
    default="false" required="true"
    shortDescription="Flag indicating copy process can be cancel. This flag is set to 'false' by default"/>

  <composite:attribute name="cancelTooltip" type="java.lang.String"
    shortDescription="tooltip for cancel button"/>

  <composite:attribute name="header" type="java.lang.String"
    shortDescription="header for panel" required="true"/>

  <composite:attribute name="oncomplete" required="true"
    shortDescription="The client-side script method to be called after complete"/>

  <composite:attribute name="onCancel" required="true"
    shortDescription="The client-side script method to be called when cancel is clicked"/>

</composite:interface>

<composite:implementation>
  <div id="#{cc.clientId}">
    <h:panelGroup layout="block" id="#{cc.clientId}-content" styleClass="panel l--push-top-1 #{cc.attrs.actionBean.inProgress ? '' : 'is-hidden'}">
      <h:panelGroup layout="block"  styleClass="panel__header"
        rendered="#{cc.attrs.actionBean.inProgress}">

        <zanata:confirm-modal id="#{cc.clientId}-cancelCopyModal"
          title="#{cc.attrs.cancelTooltip}"
          message="#{msgs['jsf.copyVersion.cancel.confirm']}"
          onresponse="#{cc.clientId}OnCancelCopyResponse"/>

        <script type="application/javascript">
          function #{cc.clientId}OnCancelCopyResponse(cancel) {
            if (cancel) {
              #{cc.attrs.onCancel}
            }
            zanata.modal.hide('##{cc.clientId}-cancelCopyModal')
          }
        </script>

        <h:panelGroup layout="block"
          styleClass="panel__header__actions l--push-right-half l--push-bottom-0"
          rendered="#{cc.attrs.canCancelProcess}">
          <a href="javascript:void(0)" class="button--small button--link"
            data-toggle="modal"
            data-target="##{cc.clientId}-cancelCopyModal">
            #{msgs['jsf.Cancel']}
          </a>
        </h:panelGroup>

        <h2 class="panel__heading--small">#{cc.attrs.header}</h2>
      </h:panelGroup>

      <div class="l--pad-all-half l--push-top-quarter">
        <zanata:progressBar id="#{cc.clientId}ProgressBar"
          actionBean="#{cc.attrs.actionBean}" interval="5000"
          render="#{cc.clientId}-progress-messages"
          oncomplete="#{cc.attrs.oncomplete}"/>

        <h:panelGroup layout="block"  id="#{cc.clientId}-progress-messages"
          styleClass="txt--meta l--push-top-quarter">
          <zanata:loader layout="inline" type="loader--small"
            rendered="#{cc.attrs.actionBean.inProgress}"/>
        <span>
          <h:outputText value="#{cc.attrs.actionBean.progressMessage}"/>
        </span>
        </h:panelGroup>
      </div>
    </h:panelGroup>
  </div>
</composite:implementation>
</html>
